package com.goldsprite.microhorigame.ecs.fsms.states;

import com.goldsprite.gameframeworks.log.Debug;

public class EntityHurtState extends EntityState {
	@Override
	public boolean canEnter() {
		return fsm.getInputs().getKeyHurt();
	}

	@Override
	public boolean canExit() {
		return fsm.getAnims().isAnimCompleted();
	}

	@Override
	public void enter() {
		fsm.getInputs().setKeyHurt(false);

		fsm.getAnims().playAnim("Hurt", true);
		fsm.getProps().hurt(fsm.getHurtDamage());//扣血
		Debug.logT("GFsm", "实体%s受伤: 扣血: %s, 当前血量: %s", fsm.getName(), fsm.getHurtDamage(), fsm.getProps().getHealth());
	}

	@Override
	public void running() {
		if(fsm.getAnims().isAnimCompleted()) {
			if (fsm.getProps().isDead())
				fsm.getInputs().setKeyDeath(true);
		}
	}
}
